package com.example.demo.service.Impl;

import com.example.demo.service.QuickPayApiService;
import com.example.demo.util.HttpClient431Util;
import com.example.demo.util.TestHelper;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class QuickPayApiServiceImpl implements QuickPayApiService {
    private static final String URL = "http://test.umbpay.com.cn:12080/cashier/trans/service.do";

    @Override
    public String quickPay(String str) {
        String data = TestHelper.format(str); //格式化请求参数

        Map<String, String> paramMap = new HashMap<String, String>();
        paramMap.put("data", data);

        String resMsg = null;
        try {
            resMsg = HttpClient431Util.doPost(paramMap, URL);
        } catch (Exception e1) {
            e1.printStackTrace();
        }

        //todo  解密
        //3.解密返回参数并验签
        String msg = TestHelper.decode(resMsg);

//        if(verify){
//            System.out.println("验签成功" + TestHelper.getDate()  + "  "  +  TestHelper.getTime());
//        }else{
//            System.out.println("验签失败！");
//
//        }
        return msg;


    }


}
